import { SwaggerRouter } from "koa-swagger-decorator";
import { UserController } from "../controller/user.controller.js";
import { registerExtraComponents } from "../common/swagger-extra.ts";
import { AuthController } from "@/controller/auth.controller.ts";
import { RoleController } from "@/controller/role.controller.ts";
import { MenuController } from "@/controller/menu.controller.ts";
import { OperLogController } from "@/controller/operLogs.controller.ts";
import { UploadController } from "@/controller/uploadcontroller.ts";

const router = new SwaggerRouter({
  spec: {
    info: {
      title: "后台管理 API",
      version: "v1.0",
    },
  },
  swaggerHtmlEndpoint: "/swagger-html",
  swaggerJsonEndpoint: "/swagger-json",
});

router.prefix("/api");

registerExtraComponents(router.registry);

// apply swagger docs routes
// 只开发环境运行
if (process.env.NODE_ENV === "development") {
  router.swagger();
}
// register user defined routes implementation
router.applyRoute(UserController);
router.applyRoute(AuthController);
router.applyRoute(RoleController);
router.applyRoute(MenuController);
router.applyRoute(OperLogController);
router.applyRoute(UploadController);
// .applyRoute(DemoController); // chained for more then one controller imports

export default router;
